package relationships;

/**
 *
 * @author arthiramachandran
 */
public class RelationshipTypes {

    public static final int PARENT_CHILD = 0;
    public static final int GRANDPARENT_GRANDCHILD = 1;
    public static final int SIBLINGS = 2;
    public static final int HALF_SIBLINGS = 3;
    public static final int UNRELATED = 4;
    public static final int AVUNCULAR = 5;
    public final int meiosesUp;
    public final int meiosesDown;
    public final int founders;
    /*
     * total sharing ~ 2 * 2^{-m} genome
     * number of seg ~ 100 / m cM
     * clearly this is wrong - need the appropriate ones
     */

    public RelationshipTypes(int up, int down, int founders) {
        meiosesUp = up;
        meiosesDown = down;
        this.founders = founders;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final RelationshipTypes other = (RelationshipTypes) obj;
        if (this.meiosesUp != other.meiosesUp) {
            return false;
        }
        if (this.meiosesDown != other.meiosesDown) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 97 * hash + this.meiosesUp;
        hash = 97 * hash + this.meiosesDown;
        return hash;
    }

    public boolean isInTrainingData() {
        return (this.equals(new RelationshipTypes(1, 0, 1))
                || this.equals(new RelationshipTypes(2, 0, 1))
                || this.equals(new RelationshipTypes(1, 1, 2))
                || this.equals(new RelationshipTypes(2, 1, 2))
                || this.equals(new RelationshipTypes(Integer.MAX_VALUE, Integer.MAX_VALUE, 0)));
    }

    @Override
    public String toString() {
        return "(" + this.meiosesUp + " " + this.meiosesDown + " " + this.founders + ")";
        //return "<" + individual1 + "," + individual2 + "(" + totalSharedIBD + "," + numberOfSharedSegments + "," + averageSharedIBD + ")>";
    }
}
